<?php

/**
 * tmcContact form.
 *
 * @package    cpfaizenay
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrinePluginFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class tmcContactForm extends PlugintmcContactForm
{
  public function configure()
  {
      $dateWidget = new sfWidgetFormI18nDate(array(
          'format' => '%day%/%month%/%year%',
//          'month_format' => 'short_name',
          'culture' => 'fr'
        ));

        if($this->isNew()) {
            $this->widgetSchema['updated_at'] = new sfWidgetFormInputHidden();
            $this->widgetSchema['modification_user_id'] = new sfWidgetFormInputHidden();

            $this->setDefault('created_at', date('d-m-Y') );
            $this->setDefault('updated_at', date('d-m-Y') );
        }else{
            $this->widgetSchema['updated_at'] = new sfWidgetFormJQueryDate(array(
              'culture' => 'fr',
              'date_widget' => $dateWidget,
              'image' => '/images/admin/icons/small/calendar.png',
              'config' => '{}',
            ));
        }

        $this->widgetSchema['created_at'] = new sfWidgetFormJQueryDate(array(
          'culture' => 'fr',
          'date_widget' => $dateWidget,
          'image' => '/images/admin/icons/small/calendar.png',
          'config' => '{}',
        ));
        
    $this->setValidator('name', new sfValidatorString(array(), array('required' => 'Nécessaire.')));
    $this->setValidator('email', new sfValidatorEmail(array(), array('required' => 'Nécessaire.', 'invalid' => 'L\'adresse email est invalide.')));
    $this->setValidator('subject', new sfValidatorString(array(), array('required' => 'Nécessaire.')));
    $this->setValidator('message', new sfValidatorString(array(), array('required' => 'Nécessaire.')));

//    $this->addCaptcha();
    
  }

  protected function addCaptcha() {
    $this->widgetSchema['captcha'] = new sfWidgetFormReCaptcha(array(
      'public_key' => sfConfig::get('app_recaptcha_public_key')
    ));

    $this->validatorSchema['captcha'] = new sfValidatorReCaptcha(array(
      'private_key' => sfConfig::get('app_recaptcha_private_key')
    ));
  }
}
